Skip to content

Conversation

@therepanic
Copy link
Contributor

Provide a clear startup failure analysis when GrpcSecurity is requested while the gRPC server is running in servlet mode.

Closes: gh-328

Provide a clear startup failure analysis when GrpcSecurity is requested
while the gRPC server is running in servlet mode.

Closes: spring-projectsgh-328

Signed-off-by: Andrey Litvitski <[email protected]>
@therepanic
Copy link
Contributor Author

I am also open to any suggestions regarding messages in getDescription and getAction, perhaps you can describe them in more detail, idk.

Comment on lines +47 to +53
@Override
protected @Nullable FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionException cause) {
if (!isMissingGrpcSecurity(cause) || !isActuallyServletMode()) {
return null;
}
return new FailureAnalysis(getDescription(), getAction(), cause);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to call the current analyzer if and only if the thrown exception is related to GrpcSecurity and when the spring.grpc.server.servlet.enabled option is enabled and, accordingly, GrpcServlet is present in the path.

BTW, I'm not entirely sure whether GrpcServlet is always in the path or not, you can correct me if this is not the case, then we can simplify the check in isActuallyServletMode a little.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends what you mean by "always" doesn't it? If the failure analyzer is relevant then it will be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the situation where a user includes a starter, which in turn pulls in io.grpc.grpc-netty or io.grpc.grpc-servlet-jakarta.

Basically, checking for the existence of the GrpcServlet, and therefore checking whether it's in the path, is justified.

@dsyer dsyer merged commit 4a9ac12 into spring-projects:main Jan 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explain why GrpcSecurity is not available in a servlet app

2 participants